package net.sf.midollo.midlet.common;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;

public class CommandEventManager {

  protected final CommandEvent lastCommandEvent = new CommandEvent();

  public synchronized void notifyCommand(Command command, Displayable displayable) {
    this.lastCommandEvent.set(command, displayable);
    this.notifyAll();
  }

  public synchronized void waitCommand(CommandEvent commandEvent) throws InterruptedException {
    wait();
    commandEvent.copy(this.lastCommandEvent);
  }
}
